import { _decorator, Component, Node, tween, v3 } from 'cc';
import { GameManager } from '../GameManager';
const { ccclass, property } = _decorator;

@ccclass('Beginner_GuidancePanel')
export class Beginner_GuidancePanel extends Component {
    public idnex = 0;
    public Maxindex = 2;
    Show() {
        let pre = this.node.getChildByName("教程");
        pre.children.forEach(cd => { cd.active = false; })
        pre.children[this.idnex].active = true;
        if (this.idnex == 2) {
            this.node.getChildByName("关闭").active = true;
        }
        this.node.getChildByName("左翻页").active = this.idnex == 0 ? false : true;
        this.node.getChildByName("右翻页").active = this.idnex == this.Maxindex ? false : true;
    }

    Left() {
        this.idnex -= 1;
        if (this.idnex < 0) this.idnex = this.Maxindex;
        this.Show();
    }
    Right() {
        this.idnex += 1;
        if (this.idnex > this.Maxindex) this.idnex = 0;
        this.Show();
    }
    Exit() {
        let pre = GameManager.Instance.UICanvas.getChildByPath("左上角UI块/教程按钮/Tip");
        pre.active = true;
        pre.setPosition(v3(250, -20));
        tween(pre)
            .by(1, { position: v3(70, 0, 0) })
            .by(1, { position: v3(-70, 0, 0) })
            .union()
            .repeat(2)
            .call(() => {
                pre.active = false;
            })
            .start();
        this.node.active = false;
    }
}


